package com.lq.ecoldchain.ui.recharge

import android.arch.lifecycle.MutableLiveData
import android.text.Html
import com.lq.ecoldchain.base.viewmodel.BaseViewModel
import com.lq.ecoldchain.entity.AliPayBean
import com.lq.ecoldchain.internet.BaseObserver

/*
*2019/1/18 0018  11:29
*function by lq
*/
class RechargeViewModel : BaseViewModel() {
    private var payWay = 1
    val weChatPay by lazy { MutableLiveData<Boolean>() }
    val money by lazy { MutableLiveData<String>() }
    val form by lazy { MutableLiveData<String>() }

    init {
        weChatPay.value = true
    }

    fun wxPay() {
        payWay = 2
        weChatPay.value = false
    }

    fun aliPay() {
        payWay = 1
        weChatPay.value = true
    }

    fun commit() {
        BaseNetCore.ApiServiceImpl.rechargeAliPay("充值", money.value!!).compose(RxTransformer.switchSchedulers()).subscribe(object : BaseObserver<AliPayBean>() {
            override fun onSuccess(t: AliPayBean?) {

            }

            override fun onFail(code: String) {}
        })
    }


    private fun querySuccess(id: Long) {
        BaseNetCore.ApiServiceImpl.validateAliPay(id).compose(RxTransformer.switchSchedulers()).subscribe(object : BaseObserver<String>() {
            override fun onSuccess(t: String?) {}

            override fun onFail(code: String) {}
        })
    }

}